package com.yzf.enterprise.common.utils;

import com.yzf.enterprise.framework.redis.RedisCache;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * @author wangzhen
 * @Description: 全局多租户id设置
 * @date 2020/4/1
 */
@Component
public class ApiContext {
    @Autowired
    private RedisCache redisCache;

    public static final String KEY_CURRENT_PROVIDER_ID = "KEY_CURRENT_PROVIDER_ID";

    //private static final Map<String, Object> mContext = Maps.newConcurrentMap();

    public void setCurrentProviderId(String key,Long providerId) {
        //mContext.put(KEY_CURRENT_PROVIDER_ID, providerId);
        redisCache.setCacheObject(key, providerId);
    }

    public Long getCurrentProviderId(String key) {
        //return (Long) mContext.get(KEY_CURRENT_PROVIDER_ID);
        return redisCache.getCacheObject(key);
    }
}
